import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.*;
import java.io.*;
import java.util.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.event.*;




/* Calculations class. This class does all
 * of the calculations and logic needed 
 * for the VOR. It returns info to the radio
 * and mainVOR class
 *
 * Andy Tonthat, Jaimar John Sison, Chris Caoagdan
 */


public class Calculations {

	int deflection;
	String direction;
	boolean TO;
	boolean FROM;
	static boolean ABEAM;
	

	//Constructor
	public Calculations(){
		
		
	}
	
//Calculate deflection from Course

    public int deflection(int interceptedRadial, int Course) {
    
        deflection=interceptedRadial-Course;
    
       return deflection;
       }
    


//determine plane location relative to station

   public String direction(int interceptedRadial, int Course) { 
	   
	   
	   if(interceptedRadial==((Course+89)%360) || interceptedRadial==((Course-89)%360)){
	    	direction="OFF";
		    ABEAM = true;
	    }
	   //if the direction is TO the VOR, which means the
	   //intercepted radial is less than the intended course + 90 mod 360
	   //or greater than the intended course - 90 mod 360
	   if(interceptedRadial<((Course+90)%360) && interceptedRadial>((Course-90)%360)) {
			direction="TO";
	        TO = true;		
	   }
	   
	   
    
	   //if the direction is ABEAM the VOR
	    else if (interceptedRadial==((Course+90)%360) || interceptedRadial==((Course-90)%360)) {
				direction="OFF";
				ABEAM = true;
			   
	    }
	   
	    else if (interceptedRadial==((Course+91)%360) || interceptedRadial==((Course-91)%360)) {
	    	direction="OFF";
			ABEAM = true;
	    }
	  
	    	
       //if the direction is FROM the VOR.
        else {
		   direction="FROM";
		   FROM = true;
			      
        }
        return direction;
   }
   public boolean getAbeam(){
	   

	   return ABEAM;
		  
	   
   }

			
}

